package com.stackexchange.webapis
{
	import com.stackexchange.webapis.events.StackExchangeResultEvent;
	
	import org.flexunit.asserts.assertEquals;
	import org.flexunit.asserts.assertNotNull;
	import org.flexunit.asserts.assertTrue;
	import org.flexunit.async.Async;
	import org.hamcrest.core.isA;

	public class ErrorsTest extends BaseTest
	{
		[Test(async)]
		public function errorsGetByExistingId():void
		{
			function handleResult(event:StackExchangeResultEvent, passThroughData:Object):void
			{
				assertTrue(event.success);
				assertNotNull(event.data.errors);
				assertTrue(event.data.errors, isA(StackExchangeError));
				
			}
			
			var passThroughData:Object = new Object();
		    service.errors.addEventListener(StackExchangeResultEvent.ERRORS_GET_BY_ID, 
		               Async.asyncHandler(this, handleResult, TestConstants.timeout, passThroughData, handleTimeout), 
		               false, 0, true);
		    service.errors.getById(TestConstants.errorId);
		}
	}
}